<?php

class Updater extends Podcast {

	public function execute() {
		$tags = array();
		
		// iterate through all podcasts and try to update the logo
		$query = "SELECT tag, logo FROM `pp_podcasts`;";
		$result = self::$db->query($query);

		if($result) {
			while($podcast = mysql_fetch_assoc($result)) {
				$feed = new Feed($podcast["tag"]);

				$newLogo = Logo::separateFromContent($feed->getCachedContent());

				if(!$newLogo["default"] && $newLogo["image"] != $podcast["logo"]) {
					$query = "UPDATE `pp_podcasts` SET `logo` = '".$newLogo["image"]."' WHERE tag = '".$podcast["tag"]."';";
					self::$db->query($query);
					
					$tags[] = $podcast["tag"];
				}
			}
		}
		
		echo count($tags);
		echo " [ ";
		
		foreach ($tags as $tag) {
			echo "$tag ";
		}
		
		echo "]";
	}
}



?>